Skip to main content

Cloud Run Jobs Sample

Build​

  • Set an environment variable with your GCP Project ID:
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>
gcloud builds submit --pack image=gcr.io/${GOOGLE_CLOUD_PROJECT}/logger-job

Run Locally​

docker run --rm gcr.io/${GOOGLE_CLOUD_PROJECT}/logger-job

# With environment variables
docker run --rm -e FAIL_RATE=0.9 -e SLEEP_MS=1000 gcr.io/${GOOGLE_CLOUD_PROJECT}/logger-job

Test​

npm test

Create a Job​

gcloud run jobs create job-quickstart \
--image=gcr.io/$PROJECT_ID/logger-job \
--tasks 50 \
--set-env-vars=SLEEP_MS=10000 \
--set-env-vars=FAIL_RATE=0.5 \
--max-retries 10

Run the Job​

gcloud run jobs run job-quickstart